package Exercise;
//商品类
class Goods{
    private String id;
    private String name;
    private int price;
    private int count;

    public Goods(){

    }
    public Goods(String id, String name, int price, int count) {
        this.id = id;
        this.name = name;
        this.price = price;
        this.count = count;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getPrice() {
        return price;
    }

    public void setPrice(int price) {
        this.price = price;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

}
public class Duixiang {
    public static void main (String[] args){
        //对象数组，数组中存放对象
        Goods[] arr = new Goods[2];
        Goods g1 = new Goods("011","小米手机",3489,10000);
        Goods g2 = new Goods("012","小米空调",1489,20000);
        //将对象放入数组中
        arr[0] = g1;
        arr[1] = g2;
        //遍历
        for(int i = 0;i<arr.length;i++){
            Goods good = new Goods();
            good = arr[i];
            System.out.println(good.getId()+good.getName()+good.getCount()+good.getPrice());
        }
    }
}
